from elasticsearch.dsl import Document,Integer,Text,Date,Keyword,analyzer,Float




# 定义分词器：就是ik插件的配置
ik_analyzer = analyzer('ik_max_word')


class CourseDocument(Document):

    # 定义查询到的结果 承载的表
    # 创建表-->es中的索引
    # 定义字段
    course_id = Integer()
    course_name = Text(analyzer=ik_analyzer)
    course_img = Keyword()
    course_type = Integer()
    price = Float()
    original_price = Float()
    brief = Text(analyzer=ik_analyzer)
    course_level = Integer()
    pub_date = Date()
    status = Integer()
    students = Integer()
    lessons = Integer()
    pub_lessons = Integer()
    teacher_id = Integer()
    audience = Text(analyzer=ik_analyzer)
    course_description = Text(analyzer=ik_analyzer)
    outcomes = Text(analyzer=ik_analyzer)
    created_time = Date()
    updated_time = Date()
    is_deleted = Integer()
    is_show = Integer()
    course_orders = Integer()
    teacher_name = Text(analyzer=ik_analyzer)
    teacher_title = Text(analyzer=ik_analyzer)

    category_ids = Text()
    category_names = Text(analyzer=ik_analyzer)
    nav_ids = Text()
    nav_names = Text(analyzer=ik_analyzer)
    nav_display_names = Text(analyzer=ik_analyzer)


    class Index:
        name = 'course'  # 索引名称
        settings = {
            'number_of_shards': 1,  # 分片数量
            'number_of_replicas': 0  # 副本数量
        }



